package udp;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UdpServer {

	public static void main(String[] args) throws Exception{
		byte[] buf=new byte[256];
		DatagramPacket p=new DatagramPacket(buf, 256);
		
		
		DatagramSocket sk=new DatagramSocket(8888);
		sk.receive(p);
		
		InetAddress addr= p.getAddress();
		int port =p.getPort();
		DatagramPacket p1=new DatagramPacket("ask!!!".getBytes(), 0, 5, addr, port);
		sk.send(p1);
		String rec=new String(p.getData(),0,p.getLength());
		System.out.println(rec);
		sk.close();
	}

}
